﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;

namespace VisionRoc_Measure
{
    public partial class FormLoadCartoonTool : Form
    {
        FormMain m_form;
        public FormLoadCartoonTool(FormMain form)
        {
            InitializeComponent();
            m_form = form;
        }

        private Point mouseOff;//鼠标移动位置变量
        private bool leftFlag;//标签是否为左键

        private void Frm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mouseOff = new Point(-e.X, -e.Y); //得到变量的值
                leftFlag = true;                  //点击左键按下时标注为true;
            }
        }

        private void Frm_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (leftFlag)
            {
                Point mouseSet = Control.MousePosition;
                mouseSet.Offset(mouseOff.X, mouseOff.Y);  //设置移动后的位置
                Location = mouseSet;
            }
        }

        private void Frm_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (leftFlag)
            {
                leftFlag = false;//释放鼠标后标注为false;
            }
        }

        public void co()
        {
            m_form.Close();
            this.Close();
        }

        private void FormLoadCartoonTool_Load(object sender, EventArgs e)
        {
            close();
        }

        async void close()
        {
            await Task.Run(() =>
            {
                Thread.Sleep(2000);
                m_form.Close(); 
                this.close(); System.Environment.Exit(0);
            });
        }
    }
}
